package short_semester.questionnaire_planet.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import short_semester.questionnaire_planet.pojo.FillBlankQuestion;
import short_semester.questionnaire_planet.pojo.FillBlankQuestionRecord;
import short_semester.questionnaire_planet.pojo.QuestionnaireRecord;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;

public interface FillBlankQuestionRecordDao extends JpaRepository<FillBlankQuestionRecord,Integer> {
    List<FillBlankQuestionRecord> findByQuestionnaireRecord(QuestionnaireRecord questionnaireRecord);
    
    List<FillBlankQuestionRecord> findByFillBlankQuestion(FillBlankQuestion question);

    Optional<FillBlankQuestionRecord> findByQuestionnaireRecordAndFillBlankQuestion(
            QuestionnaireRecord questionnaireRecord,
            FillBlankQuestion fillBlankQuestion);

    @Modifying
    @Transactional
    void deleteByFillBlankQuestion(FillBlankQuestion fillBlankQuestion);
}
